﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonalInfo.aspx.cs" Inherits="H2.NET.Web.Workflow.Workflow.PersonalInfo" %>

<%@ Register Assembly="H2.NET.Controls" Namespace="H2.NET.Controls" TagPrefix="H2" %>
<script type="text/javascript">

    $(function () {
        $("#associateName", $.pdialog.getCurrent()).css("background-color", "#ffffff");
    });

    function AddToAssociates() {

        if ($("#associate", $.pdialog.getCurrent()).val() == "") {
            alertMsg.error("请先选择一个用户！");
            return false;
        }

        alertMsg.confirm("确定要加入到列表吗？", {
            okCall: function () {
                $.ajax({
                    type: "POST",
                    url: "Workflow/PersonalInfo.aspx?action=add_to_associates",
                    data: { associate: $("#associate", $.pdialog.getCurrent()).val() },
                    cache: false,
                    success: function (result) {
                        if (result == "true") {
                            alertMsg.correct("加入到列表成功！");
                            $.pdialog.reload("Workflow/PersonalInfo.aspx");
                        } else {
                            alertMsg.error("加入到列表失败！");
                        }
                    },
                    error: function (response) {
                        alertMsg.error(response);
                    }
                });
            }
        });
    }

    function deleteAssociate(userName) {
        alertMsg.confirm("确定要将" + userName + "移出列表吗？", {
            okCall: function () {
                $.ajax({
                    type: "POST",
                    url: "Workflow/PersonalInfo.aspx?action=delete_associates",
                    data: { associate: userName },
                    cache: false,
                    success: function (result) {
                        if (result == "true") {
                            alertMsg.correct("移出列表成功！");
                            $.pdialog.reload("Workflow/PersonalInfo.aspx");
                        } else {
                            alertMsg.error("移出列表失败！");
                        }
                    },
                    error: function (response) {
                        alertMsg.error(response);
                    }
                });
            }
        });
    }

    function winOpenPopup(strURL, str_width, str_height, str_value, str_element, str_postback, str_multiple) {

        var json = window.showModalDialog(
                strURL + "&vt=" + new Date(),
                '',
                "dialogWidth=" + (parseInt(str_width) + 30) + "px;dialogHeight=" + str_height + "px;dialogLeft: status:no; directories:yes;scrollbars:auto;Resizable=yes;");

        if (json != null && json != "" && json != undefined) {
            var obj = eval('(' + json + ')');

            $("#associate", $.pdialog.getCurrent()).val(obj.a);
            $("#associateName", $.pdialog.getCurrent()).val(obj.b);

        } else {
            $("#associate", $.pdialog.getCurrent()).val("");
            $("#associateName", $.pdialog.getCurrent()).val("");
        }
    }       
	

</script>
<div class="pageContent">
    <form id="Form1" runat="server">
    <div class="pageFormContent" style="padding: 0px;">
        <table class="table" width="100%" layouth="60">
            <thead>
                <tr>
                    <th width="200" align="center">
                        用户名
                    </th>
                    <th align="center">
                        姓名
                    </th>
                    <th width="80" align="center">
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:repeater id="gvAssociates" runat="server">
                <ItemTemplate>
                    <tr>
                        <td><%# Eval("strUserName")%></td>
                        <td><%# Eval("strUserFullName")%></td>
                        <td style="text-align: center;">
                            <a href="javascript:void(0);" onclick="return deleteAssociate('<%# Eval("strUserName")%>');">删除</a>
                        </td>
                    </tr> 
                </ItemTemplate>
                </asp:repeater>
            </tbody>
        </table>
    </div>
    <div class="formBar">
        <ul style="width: 100%;">
            <li>
                <input name="associate" id="associate" value="" type="hidden" />
                <asp:textbox runat="server" ID="txtEmail" ReadOnly></asp:textbox>
                <H2:Dialog ID="associateName" runat="server" ReadOnly CssClass="required" Width="162px"
                    Dialog_ID="SYS-0007"></H2:Dialog>
            </li>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" onclick="return AddToAssociates();">
                            加入到列表</button>
                    </div>
                </div>
            </li>
            <li style="float: right;">
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">
                            关闭窗口</button></div>
                </div>
            </li>
        </ul>
    </div>
    </form>
</div>
